<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>行内元素水平居中</title>
    <style type="text/css">
        .box{
            width: 200px;
            height: 200px;
            background-color: red;
            color: #fff;
            /* 方式一 */
            /* text-align: center;
            line-height: 200px; */

            /* 方式二 */
            display: table-cell;
            text-align: center;
            vertical-align: middle;
        }
    </style>
</head>
<body>
    <div class="box">
        tanjinlin
    </div>
</body>
</html>